<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>登录 - Mubea</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit" />
<link rel="shortcut Icon" href="/favicon.ico" type="image/x-icon" />
<link href="../source/css/base.css" rel="stylesheet" type="text/css" />
<link href="../source/css/main.css?v0619" rel="stylesheet" type="text/css" />
<link href="../source/css/element-ui@2.4.0.index.css" rel="stylesheet" type="text/css" />

</head>
    <div id="app" class="login">
        <div class="header">
            <div class="base-width">
                <a href="./main.html">
                    <img class="logo" src="../source/img/logo.png" alt="" />
                </a>
            </div>
        </div>

        <div class="base-width">
            <div class="banner">
                <img src="../source/img/Teaser_global.png" alt="">
            </div>

            <el-form :model="loginForm" :rules="rules" ref="ruleForm" label-width="100px" class="login-form">
                <el-form-item label="用户名" prop="username">
                    <el-input v-model="loginForm.username" placeholder="用户名"></el-input>
                </el-form-item>

                <el-form-item label="密码" prop="pwd">
                    <el-input type="password" v-model="loginForm.pwd" placeholder="密码"></el-input>
                </el-form-item>

                <div class="forget-pwd tr">
                    忘记密码
                </div>

                <el-form-item>
                    <el-button type="primary" class="login-btn" @click="submitForm('ruleForm')">登录</el-button>
                </el-form-item>
            </el-form>

            <div class="supplier">
                我是供应商，<a class="supplier-link" href="./supplier_reg.html">立即注册</a>
            </div>
        </div>
    </div>



<script src="../source/js/lib/vue.min.js"></script>
<script src="../source/js/lib/element-ui@2.4.0.index.js"></script>
<script src="../source/js/lib/jquery.min.js"></script>
<script src="../source/js/common.js?20180622"></script>
<script>
    var app = new Vue({
        el:'#app',
        data : {
            loginForm: {
                username: '',
                pwd: '',
                type:0,
                account:user.account,
                key:user.key,
            },
            rules: {
                username: [
                    { required: true, message: '请输入用户名', trigger: 'blur' },
                    // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
                ],
                pwd: [
                    { required: true, message: '请输入密码', trigger: 'blur' }
                ]
            }
        },
        mounted:function(){

        },
        methods: {
            apiLogin:function(){
                var _this = this;
                $.ajax({
                    url:apiUrl+'/ChkLogin',
                    type:'GET',
                    data:{'json':JSON.stringify(_this.loginForm)},
                    //dataType :'jsonp',
                    success:function(datas){
                        console.log('datas',datas)
                        if(datas.Success===true){
                            setCookie('username',encodeURIComponent(_this.loginForm.username),72);
                            setCookie('type',datas.Type,72);  /*0：计划员，1：供应商，2：后台管理员*/
                            // setCookie('EmpCode',datas.EmpCode,720);
                            location.href='./main.html?v0619';
                        }else{
                            _this.$message.error(datas.Msg);
                        }
                    },
                    error:function(datas){
                        _this.$message.error(datas.Msg);
                    }
                });
            },
            submitForm:function(formName) {
                var _this = this;
                this.$refs[formName].validate(function(valid){

                    console.log('valid',valid)
                    if (valid) {
                        _this.apiLogin();
                    } else {
                        // console.log('error submit!!');
                        return false;
                    }
                });
            }
        }
    })
</script>
</body>
</html>